#ifndef __LIB_MSG_QUEUE
#define __LIB_MSG_QUEUE

#include "kfifo.h"
#include <stdint.h>

template <typename T>
class msg_queue : public kfifo
{
public:
	msg_queue(void *mem, size_t mem_size)
		:kfifo((uint8_t*)mem, mem_size),
		size(sizeof(T))
	{

	}

	~msg_queue() {	}

	uint32_t put(const T* ptr, uint32_t length)
	{
		return this->kfifo_put((const uint8_t*)ptr, length * this->size) / this->size;
	}

	uint32_t get(T* ptr, uint32_t length) 
	{
		return this->kfifo_get((uint8_t*)ptr, length * this->size) / this->size;
	}

private:
	const size_t size;
};

#endif

